local chitao = fk.CreateSkill{
  name = "wk_heg__chitao",
}

Fk:loadTranslationTable{
  ["wk_heg__chitao"] = "敕讨",
  [":wk_heg__chitao"] = "其他角色的结束阶段，若你本回合成为过其使用牌的目标，你可将一张牌置于牌堆顶，令一名除其外的其他角色视为对其使用一张【杀】。",
  ["#wk_heg__chitao-choose"] = "敕讨：你可以将一张牌置于牌堆顶并选择一名除你与当前回合外的角色，其对当前回合角色视为使用一张【杀】",

  ["$wk_heg__chitao1"] = "子通专恣，必谋而诛之！",
  ["$wk_heg__chitao2"] = "孙綝久专，不可久忍，必溃诛！",
}

chitao:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    if not (player:hasSkill(self) and player ~= target and target.phase == Player.Finish) then return false end
    local events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
      local use = e.data
      return table.contains(use.tos, player) and use.from == target
    end, Player.HistoryTurn)
    return #events > 0
  end,
  on_cost = function (self, event, target, player, data)
    local targets = table.filter(player.room.alive_players, function (p) return p ~= player and p ~= target end)
    local tos, card = player.room:askToChooseCardsAndPlayers(player, {
      min_card_num = 1,
      max_card_num = 1,
      min_num = 1,
      max_num = 1,
      targets = targets,
      skill_name = chitao.name,
      prompt = "#wk_heg__chitao-choose",
      cancelable = true,
      will_throw = false,
    })
    if #tos > 0 then
      event:setCostData(self, {card = card, tos = tos[1]})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local card = event:getCostData(self).card
    local to = event:getCostData(self).tos
    room:moveCards({
      ids = card,
      from = player,
      toArea = Card.DrawPile,
      moveReason = fk.ReasonJustMove,
      skillName = chitao.name,
      proposer = player,
    })
    room:useVirtualCard("slash", nil, to, target, chitao.name, true)
  end,
})

return chitao